<?php

use App\Models\CallBack;
use App\Models\CallRecords;
use App\Models\Client;
use Illuminate\Database\Seeder;
use App\Models\ClientRecords;

class ClientSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $faker = Faker\Factory::create('zh_CN');


        $rs = Client::query()
            ->whereNotNull('employee_id')
//            ->where('true_client',1)
//            ->count()
            ->each(function ($model){
                $posts = factory(\App\Models\ClientRecords::class)
                    ->times(random_int(1,3))
                    ->make()
                    ->each(function ($data) use ($model){
                        $data->client_id = $model->id;
                        $data->employee_id = $model->employee_id;
                    });
                ClientRecords::insert($posts->toArray());
            })
        ;

        dd($rs);

    }
}
